package qq;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Objects;

interface ListInterface1<T> {
    void Init(int initsize);//初始化表
    int length();
    boolean isEmpty();//是否为空
    int ElemIndex(T t);//找到编号
    T getElem(int index) throws Exception;//根据index获取数据
    void add(int index,T t) throws Exception;//根据index插入数据
    void delete(int index,int... times) throws Exception;
    void add(T t) throws Exception;//尾部插入
    void set(int index,T t) throws Exception;
    String toString();//转成String输出
}

class SeqList1<T> implements ListInterface1<T> {
    private Object[] date;//数组存放数据
    private int lenth;
    public void seqlist() {//初始大小默认为10
        Init(10);
    }

    public void Init(int initsize) {//初始化
        this.date=new Object[initsize];
        lenth=0;
    }
    public int length() {
        return this.lenth;
    }

    public boolean isEmpty() {//是否为空
        if(this.lenth==0)
            return true;
        return false;
    }

    /*
     * * @param t
     * 返回相等结果，为-1为false
     */
    public int ElemIndex(T t) {
        for(int i=0;i<date.length;i++)
        {
            if(date[i].equals(t))
            {
                return i;
            }
        }
        return -1;
    }

    /*
     *获得第几个元素
     */
    public T getElem(int index) throws Exception {
        if(index<0||index>lenth-1)
            throw new Exception("数值越界");
        return (T) date[index];
    }

    public void add(T t) throws Exception {//尾部插入
        add(lenth,t);
    }

    /*
     *根据编号插入
     */
    public void add(int index, T t) throws Exception {
        if(index<0||index>lenth)
            throw new Exception("数值越界");
        if (lenth==date.length)//扩容
        {
            Object[] newdate = new Object[lenth*2];
            System.arraycopy(date, 0, newdate, 0, lenth);
            date=newdate;
        }
        for(int i=lenth-1;i>=index;i--)//后面元素后移动
        {
            date[i+1]=date[i];
        }
        date[index]=t;//插入元素
        lenth++;//顺序表长度+1

    }

    public void delete(int index,int... times) throws Exception {
        for(int i=index;i<lenth;i++)//index之后元素前移动
        {
            date[i]=date[i+1];
        }
        lenth--;//长度-1
    }

    @Override
    public void set(int index, T t) throws Exception {
        if(index<0||index>lenth-1)
            throw new Exception("数值越界");
        date[index]=t;
    }
    public String toString() {
        StringBuilder vaString= new StringBuilder();
        for(int i=0;i<lenth - 1;i++)
        {
            vaString.append(date[i].toString()).append(" ");
        }
        vaString.append(date[lenth - 1].toString());
        return vaString.toString();

    }
}

class Opts {
    public ArrayList<String[]> o;
    public int times;
    public SeqList1<Integer> s;
    Opts(SeqList1<Integer> s){
        this.s = s;
        this.times = 1;
        this.o = new ArrayList<>();
    }

    public void add(Integer i ) throws Exception {
        this.s.add(i);
    }
    public void setO(String[] s){
        o.add(s);
    }
    public void open() throws Exception {
        for(String[] i : o) {
            if(Objects.equals(i[0], "Insert")){
                s.add(Integer.parseInt(i[1]),Integer.parseInt(i[2]));
                this.times++;
            } else if (Objects.equals(i[0], "Delete")) {
                try {
                    for(int j = Integer.parseInt(i[1])-1;j<=Integer.parseInt(i[2])-1;j++){
                        s.delete(j,this.times);
                    }
                }catch (Error ignored){
                }finally {
                    this.times++;
                }
            }
        }
    }
}

public class T {
    public static void main(String[] args) throws Exception {
        BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
        scanner.readLine();
        SeqList1<Integer> l =  new SeqList1<>();
        l.Init(99999);
        Opts o = new Opts(l);

        String[] s1 = scanner.readLine().split(" ");
        for(String ss:s1){
            o.add(Integer.parseInt(ss));
        }
        String s = scanner.readLine();
        while (!s.contains("0 0")){
            o.setO(s.split(" "));
            s = scanner.readLine();
        }
        o.open();
        System.out.println(o.s);
    }
}
